/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.generator.adapter;

import java.util.Collection;
import ru.jSky.factory.GlobalSelectorByEdidFactory;
import ru.jSky.generator.ItemsGenerator;
import ru.jSky.interfaces.Armor;
import ru.jSky.interfaces.Major;
import ru.jSky.selector.SelectorByEdid;

/**
 *
 * @author Rakev
 */
public abstract class AbstractAutoSelectionItemsGeneratorAdapter<T extends Major> implements AutoSelectionItemsGenerator<T> {

    private ItemsGenerator<T> adaptedGenerator;

    public AbstractAutoSelectionItemsGeneratorAdapter(ItemsGenerator<T> adaptedGenerator) {
        this.adaptedGenerator = adaptedGenerator;
    }

    @Override
    public Collection<T> generate(String baseItemRegex) {
        Collection<T> baseItems = selectBaseItem(baseItemRegex);
        return adaptedGenerator.generate(baseItems);
    }

    private Collection<T> selectBaseItem(String baseItemRegex) {
        SelectorByEdid<T> selector = createSelector();
        Collection<T> selected = selector.select(baseItemRegex);
        return selected;
    }

    protected abstract SelectorByEdid<T> createSelector();
}
